package com.ihd.ihardware.app;


import android.graphics.Color;
import android.graphics.Rect;
import android.widget.LinearLayout;

import com.baidu.mapapi.SDKInitializer;
import com.ihd.ihardware.R;
import com.ihd.ihardware.common.widget.CustomTopBar;
import com.ihd.ihardware.pojo.MembersRes;
import com.tencent.mm.opensdk.openapi.IWXAPI;
import com.tencent.mm.opensdk.openapi.WXAPIFactory;

import org.jaaksi.pickerview.picker.BasePicker;
import org.jaaksi.pickerview.topbar.ITopBar;
import org.jaaksi.pickerview.util.Util;
import org.jaaksi.pickerview.widget.DefaultCenterDecoration;
import org.jaaksi.pickerview.widget.PickerView;

import java.util.ArrayList;
import java.util.List;

import cn.jpush.android.api.JPushInterface;
import cn.wowjoy.commonlibrary.app.BaseApplication;


public class MyApplication extends BaseApplication {

    public static List<MembersRes.DataBean> membersData = new ArrayList<>();
    public static MembersRes.DataBean memberId = new MembersRes.DataBean();
    public static IWXAPI api;

    @Override
    public void onCreate() {
        super.onCreate();

        membersData = new ArrayList<>();
        initDefaultPicker();

        memberId.setMemberId("");
        api = WXAPIFactory.createWXAPI(this, "wxba7a23cd9235211a", true);
        api.registerApp("wxba7a23cd9235211a");

        JPushInterface.setDebugMode(false);
        JPushInterface.init(this);

        SDKInitializer.initialize(this);
    }

    private void initDefaultPicker() {
        PickerView.sDefaultVisibleItemCount = 5;
        // BasePickerView
        PickerView.sDefaultItemSize = 40;
        PickerView.sDefaultIsCirculation = false;

        // PickerView
        PickerView.sOutTextSize = 16;
        PickerView.sCenterTextSize = 18;
        PickerView.sCenterColor = getResources().getColor(R.color.C_46A5F9);
        PickerView.sOutColor = getResources().getColor(R.color.C_E8E9F0);

        // BasePicker
        int padding = Util.dip2px(this, 20);
        BasePicker.sDefaultPaddingRect = new Rect(padding, padding, padding, padding);
        BasePicker.sDefaultPickerBackgroundColor = Color.WHITE;
        // 自定义 TopBar
        BasePicker.sDefaultTopBarCreator = new BasePicker.IDefaultTopBarCreator() {
            @Override
            public ITopBar createDefaultTopBar(LinearLayout parent) {
                return new CustomTopBar(parent);
            }
        };

        DefaultCenterDecoration.sDefaultLineWidth = 1;
        DefaultCenterDecoration.sDefaultLineColor = getResources().getColor(R.color.C_46A5F9);
        int leftMargin = Util.dip2px(this, 10);
        int topMargin = Util.dip2px(this, 2);
        DefaultCenterDecoration.sDefaultMarginRect = new Rect(leftMargin, -topMargin, leftMargin, -topMargin);
    }
}
